package edu.gatech.oad.user;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class LoginControllerTest {
	/**
	 * Tests if you fail the log in once
	 */
	@Test public void logInSuccess(){
		Patient patient = AccountsController.sharedController().addPatientForUsername("A");
		patient.setPassword("B");
		LoginController loginController = new LoginController();
		User result = loginController.login("A", "B");
		assertTrue(patient.equals(result));
	}
	
	
	
	/**
	 * Tests if you fail the log in once
	 */
	@Test public void logInUserFailOnce(){
		Patient patient = AccountsController.sharedController().addPatientForUsername("B");
		patient.setPassword("C");
		LoginController loginController = new LoginController();
		User result = loginController.login("B", "A");
		assertTrue(patient != result);
		assertFalse("The Person Did Not Log In", (patient == result));
	}
	
	/**
	 * Tests both if you fail 3 times, try to login, can't
	 */
	@Test public void logInUserSuspended(){
		Patient patient = AccountsController.sharedController().addPatientForUsername("C");
		patient.setPassword("B");
		LoginController loginController = new LoginController();
		User result = loginController.login("C","A");
		result = loginController.login("C","A");
		result = loginController.login("C","A");
		result = loginController.login("C", "B");
		assertFalse(patient.equals(result));
	}
}
